/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-07-15
 * Time: 22:08
 */
public class test1 {
    public int searchInsert(int[] nums, int target) {
        int n = nums.length;
        int left = 0,right=  n-1;
        while(left<right){
            int mid = (right-left)/2+left;
            if(nums[mid]==target){
                return mid;
            }else if(nums[mid]<target){
                left = mid+1;
            }else{
                right = mid;
            }
        }
        return nums[left]<target?left+1:left;
    }
}
